package com.yand.config.rabbitmq;


import org.springframework.amqp.core.*;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class RabbitMQConfig {


    /**
     * 定义队列名
     */
    private final static String queueName = "testQueue";

    /**
     * 定义string队列
     * @return
     */
    @Bean(name ="testQueue")
    public Queue string() {
        return new Queue(queueName);
    }


    /**
     * 定义一个交换机
     * @return
     */
    @Bean
    public TopicExchange exchange(){
        return new TopicExchange("exchange");
    }

    @Bean
    Binding bindingExchangeMessages(@Qualifier("testQueue") Queue queueMessages, TopicExchange exchange){
        return BindingBuilder.bind(queueMessages).to(exchange).with(queueName);
    }

}
